<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>根据宽度 改变背景颜色</title>
    <style>
        body{
            width: 100%;
            height: 100%;
            background-color: rgb(255, 0, 0);
        }
        @media screen and (max-width: 1000px) {
            body{
                background-color: rgb(0, 255, 0);
            }
        }
        @media screen and (max-width: 500px) {
            body{
                background-color: rgb(0, 0, 255);
            }
        }
    </style>
</head>
<body>
    
</body>
</html>